package com.lemobar.pay.enums;

import lombok.Getter;


/**
 * 双乾交易状态枚举.
 *     双乾订单交易状态：
 *        0	失败
 *        1	成功
 *        2	待处理
 *        3	取消
 *        4	结果未返回
 *
 */
@Getter
public enum EPayOrderStatusEnum {

    FAIL("0", "失败"),

    SUCCESS("1", "成功"),

    PENDING("2", "待处理"),

    CANCEL("3", "取消"),

    UNKNOW("4", "结果未返回"),

    ;

    private String code;
    private String desc;

    EPayOrderStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static EPayOrderStatusEnum findByCode(String code) {
        for (EPayOrderStatusEnum statusEnum : EPayOrderStatusEnum.values()) {
            if (code.toLowerCase().equals(statusEnum.getCode().toLowerCase())) {
                return statusEnum;
            }
        }
        return EPayOrderStatusEnum.UNKNOW;
        //throw new RuntimeException("错误的双乾支付状态 " + code);
    }
}
